package com.ifnk.portaljava.hlyt.springutil;


import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;


/**
 * Bean Locator, get bean by name
 *
 * @author lifan 12-5-25 11:23
 * @version $Revision$
 */
public class ServiceLocator implements BeanFactoryAware {
    private static BeanFactory beanfactory;

    /**
     *
     */
    public static Object getBean(String name) {
        if (beanfactory == null)
            return null;

        return beanfactory.getBean(name);
    }

    /**
     *
     */
    public void setBeanFactory(BeanFactory arg0) throws BeansException {
        beanfactory = arg0;
    }
}
